package com.google.code.puertorico.actors

import actors.Actor
import com.google.code.puertorico.{ActionSequence, BoardState}

object EndTurnActor extends Actor {
  def act() {
    loop {
      react {
        case ActionSequence(state, actions) => {
          if (state.activePlayerHasStrategyCard) {
            // Forward to EndOfRoundActor
            EndRoundActor ! ActionSequence(state, actions);
          } else {
            val newState = state.copy(activePlayer = state.nextActivePlayer);
            ChooseStrategyCardActor ! newState;
          }
        }
      }
    }
  }
}